<?php


namespace app\common\caches;


use think\facade\Cache;

class SmsCache
{
    /**
     * @todo 缓存手机验证码
     * @param string $phone 手机号
     * @param string $code  验证码
     * @return bool
     */
    public static function setVerifyCode(string $phone, string $code)
    {
        return Cache::tag("sms:{$phone}")->set("sms.phone:{$phone}.verify", $code, 5 * 60);
    }

    /**
     * @todo 获取手机验证码
     * @param string $phone 手机号
     * @return mixed
     */
    public static function getVerifyCode(string $phone)
    {
        return Cache::get("sms.phone:{$phone}.verify");
    }

    /**
     * @todo 移除手机验证码
     * @param string $phone 手机号
     * @return bool
     */
    public static function removeVerifyCode(string $phone)
    {
        return Cache::delete("sms.phone:{$phone}.verify");
    }
}
